% Features function takes an image as an input and returns
% a data structure containing the row and column values
% of where the features were found.

function [r,c] = features(i)

% Call the canny edge detector on the image,
% sigma 3 to get rid of fine detail.
x = edge(i,'canny',[],3);    

% Convert the image from a 'logical' to 'double' so that
% it can be convolved with a mask.
j = double(x);

% Convolve the image with a Gaussian smoothing mask. 
mask = fspecial('gaussian',100,4);  
Imout = convolve2(j,mask,'same'); 

% Call the findpeaks function on the image to find
% local maxima.
[r,c,v] = findpeaks(Imout); 

% A threshold for the peaks.
ok = v > 0.09; 
r = r(ok);
c = c(ok);
